package TCP.Test2;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.Socket;

//助理
public class MsgThread implements Runnable{
    Socket socket = null;

    public MsgThread(Socket socket){
        this.socket = socket;
    }
    @Override
    public void run() {
        try {
            InputStream is =socket.getInputStream();
            //构建对象流
            ObjectInputStream ois = new ObjectInputStream(is);
            User user = (User)ois.readObject();
            System.out.println("客户端"+socket.getInetAddress()+"说："+user);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
